//
//  AttributeStringController.swift
//  EasyCoding_Example
//
//  Created by 范晓鑫 on 2021/2/10.
//  Copyright © 2021 CocoaPods. All rights reserved.
//

import UIKit
import EasyCoding

class AttributeStringController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        
        let varText = "字符串变量"

        let attr = NSAttributedString.easy.build(.color(.blue), .font(size: 15)) {
            "我是一段富文本，写起来很方便，比如这个"
            "红色的小字".easy.attr(.color(.red), .font(size: 11))
            "和这个"
            "绿色的大字".easy.attr(.color(.green), .boldFont(size: 20))
            varText.easy.attr(.color(.orange), .event {
                print("点击了这串字")
            })
        }
        
        let text = NSMutableAttributedString(.color(.blue), "fuck")
        text.set(.color(.red))
        text.set(.color(.red), for: "u")
        text.set(.color(.red), at: 1, count: 100)
        text.set(.color(.red), regex: "")
        text.insert(.color(.blue), for: "", at: 1)
        text.insert("", at: 1)
        
        let text = NSAttributedString(.color(.blue), .font(size: 15)) {
            "这是一段文字"
            "这是另一段文字".set(.color(.red))
        }
        
        let text = "FUCK".asAttributed(.color(.blue))
        
        let label = ECLabel.easy(
//            .attr("我是一段富文本，写起来很方便，比如这个\("红色的小字", .color(.red), .font(size: 11))和这个\("绿色的大字", .color(.green), .boldFont(size: 20))。\(string: varText, .color(.orange), .event { print("点击了这串字") })",
//                .color(.blue), .font(size: 15)),
            .text(attr),
            .lines(), .userInteraction())
        self.view.easy.config(.bg(.white))
            .add(label, layout: .centerY, .marginX(20))
    }
}
